#jinja2: trim_blocks: False
global
  chroot /var/lib/haproxy
  user haproxy
  group haproxy
  daemon
  log {{ syslog_server }}:{{ syslog_udp_port }} {{ syslog_haproxy_facility }}
  maxconn {{ haproxy_max_connections }}
  stats socket /var/lib/haproxy/stats
defaults
  log global
  mode http
  option redispatch
  option httplog
  option forwardfor
  retries 3
  timeout http-request 10s
  timeout queue 1m
  timeout connect 10s
  timeout client {{ haproxy_client_timeout }}
  timeout server {{ haproxy_server_timeout }}
  timeout check 10s
  balance {{ haproxy_defaults_balance }}

listen stats
   bind {{ api_interface_address }}:{{ haproxy_stats_port }}
   mode http
   stats enable
   stats uri /
   stats refresh 15s
   stats realm Haproxy\ Stats
   stats auth {{ haproxy_user }}:{{ haproxy_password }}

{% if enable_mariadb | bool %}
listen mariadb
  mode tcp
  timeout client 3600s
  timeout server 3600s
  option tcplog
  option tcpka
  option mysql-check user haproxy post-41
  bind {{ cell_vip_address }}:{{ mariadb_port }}
{% for host in groups[nova_cell_conductor_group] %}
  server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mariadb_port }} check inter 2000 rise 2 fall 5 {% if not loop.first %}backup{% endif %}
{% endfor %}
{% endif %}

{% if enable_nova | bool %}
listen nova_novncproxy
  bind {{ cell_vip_address }}:{{ nova_novncproxy_port }}
  timeout tunnel 1h
{% for host in groups[nova_cell_novncproxy_group] %}
  server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ nova_novncproxy_port }} check inter 2000 rise 2 fall 5
{% endfor %}
{% endif %}
